package app.nbdevices.controller;


import app.nbdevices.api.dto.ResponseCode;
import app.nbdevices.service.INbDevService;
import app.nbdevices.service.IFaultService;
import app.nbdevices.vo.RegisterInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;


/**
 * 这是业务主控制器，主要用来处理与设备相关的业务逻辑
 */
@RestController
public class AppController {
    @Autowired
    @Qualifier("FaultService")
    IFaultService svcFault;
//
   @Autowired
    INbDevService nbDevService;

    /**
     * 单个设备注册
     */
    @PostMapping("/devRegister")
    public void DeviceRegis(@ModelAttribute RegisterInfoVo vo){
        System.out.println("dddddd");
        nbDevService.addDev(vo);
    }
    /**
     * 批量文件注册
     */
    @PostMapping("/lotRegister")
    public void lotRegis(@RequestParam("files") MultipartFile xlsFile,@RequestParam("productId") int pid) throws Exception {
        if(xlsFile!=null){
            System.out.println(xlsFile.getOriginalFilename()+pid);
            System.out.println("not null");
            nbDevService.lotAddDev(xlsFile,pid);
        }else{
            System.out.println("null");
        }
    }
    @PostMapping("/getdevinfo")
    public void getDevInfo(){

    }





}
